//--------------------------------------------
//  Author        : Santosh Poojari
//  Created Date  : 22/02/2008
//  Email ID      : santosh.poojari@gmail.com
//--------------------------------------------

#region References
using System;
using System.Collections.Generic;
using System.Text;

using Project.Practice.MVP.Domain;
#endregion

namespace Project.Practice.MVP.Presenter
{
    public class CalculationPresenter : BasePresenter
    {
        #region Public Members
        private ICalculationView m_View = null;
        #endregion

        #region Public Constructor
        public CalculationPresenter(ICalculationView view)
            : base()
        {
            m_View = view;
        }
        #endregion

      
        public void Initialize()
        {
            //Security Check
            //If(user session expires Or login user fails
            //Throw New CriticalLayerException()
        }
        public void AddNumbers()
        {
            try
            {
                m_View.Result= Convert.ToString(AddOperations());               
            }
            catch (Exception ex)
            {
                ProcessPresenterLayerException(ex);
            }
        }
        private int AddOperations()
        {
            int result = m_View.Numbers1 + m_View.Numbers2;
            return m_Service.AddOperation(result);
        }
    }
}